
import React  from 'react'
import {Table} from 'antd'
import style from './index.less'


/**
 * 自定义分页的表格
 * @param {[type]} columns    [表格列定义]
 * @param {[type]} dataSource [表格数据源]
 * @param {[type]} pageSize   [每页显示条数]
 */
const TableListWithRowClick=({
	columns,
	dataSource,
	pageSize,
	dispatch,
	rowUrl,
	tag,
	begindate,
	enddate,
	filterValue
})=>{
	const pageProps={
		showSizeChanger:true,
		defaultCurrent:1,
		total:dataSource.length,
		pageSize:pageSize||10,
		showTotal:total => `共 ${total} 条记录`
	}
  const onRowClick=(record, index, e) => {
		const timestamp=Date.parse(new Date())/1000
    dispatch({
      type:`${tag}/changeRouter`,
      payload:{
        pathname:rowUrl,
        query:{
					trader:record.trader,
					begindate,
					enddate,
					filterValue,
					at:timestamp,
        }
      }
    })
   }
	return (
		// <div style={{padding:'0 15px 15px'}} className="pageTable">
		<div style={{padding:'0 0 15px'}} className="pageTable">
			<Table
				dataSource={dataSource}
				columns={columns}
				rowKey={row => row.trader + row.groupid}
				pagination={pageProps}
				onRowClick={onRowClick}
			 />
		</div>
	)
}

TableListWithRowClick.propTypes={
	// data
}

export default TableListWithRowClick
